#include "LSM.h"

int main(int argc, char* argv[]){
  std::string garbage;
  double init1,init2,tol,lambda;
  std::fstream Input("Inputfile");
  getline(Input,garbage,'\n');
  Input >> init1 >> init2 >> tol >> lambda;
  Input.close();  
  LSM<2,11> lsm;
  lsm.load_data("data");
  double initial[2] = {init1,init2};
  double* result = lsm.LM(initial,tol,lambda);
  std::cout << "a1 = " << result[0] << " , " << "a2 = " << result[1] << std::endl;
  double f = lsm.f(lsm.r(result));
  double** data = lsm.get_data();
  std::cout << "result by formula  result from datas" << std::endl;
  for(int i = 0; i < 11 ; i++){
    double rs = lsm.get_func()->cal_func(data[i][0],result);
    std::cout << rs << "              " << data[i][1] <<  std::endl;
  }
  return 0;
}
